package com.tina.common;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Tina
 * @version 1.0
 * @since 2021/10/18 09:39
 **/
public class ResultUtils {

    public static Map<String, Object> result(int code, String msg, Object data) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", code);
        map.put("msg", msg);
        map.put("data", data);
        return map;
    }

    public static Map<String, Object> result(int code, String msg) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", code);
        map.put("msg", msg);
        return map;
    }

    public static Map<String, Object> result(String msg) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", msg);
        return map;
    }

    public static Map<String, Object> result() {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "操作成功");
        return map;
    }

    public static Map<String, Object> result(int code) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", code);
        map.put("msg", "操作成功");
        return map;
    }

    public static Map<String, Object> result(Boolean flag) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", flag ? 200 : 500);
        map.put("msg", "操作成功");
        return map;
    }

    public static Map<String, Object> result(int code, Object data) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", code);
        map.put("msg", "操作成功");
        map.put("data", data);
        return map;
    }
    public static Map<String, Object> result( Object data) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "操作成功");
        map.put("data", data);
        return map;
    }


}
